	<link rel='stylesheet' type='text/css' href='<?php echo base_url()?>css/redmond/jquery-ui-1.8.1.custom.css'/>
	<script type='text/javascript' src='<?php echo base_url()?>js/jquery-ui-1.8.1.custom.min.js'></script>

	<div id="submenu" class="btn">
<?php echo anchor('patient/new_patient', lang('menuitem_add_new'))?>
	</div>
	<br>
	<br>
	
	<?php
		//print how much patient(s) we get
		echo $count.' '.lang('general_record_found');
			
	?>
	
	<?php if($count > 0) {?>
	
	<script>
	$(function() {
		$("#patient_id2").autocomplete({
			source: "<?php echo site_url()?>?c=search&m=patient",
			minLength: 1,
			select: function(event, ui) {
				$("#searched_id").val(ui.item.id);
                                $("#code").html((ui.item.code));
                                $("#paname").html((ui.item.value));
                                $("#history_link").attr("href",'patient/patient_history/'+(ui.item.id));
                                $("#details_link").attr("href",'patient/patient_details/'+(ui.item.id));
                                $("#payment_link").attr("href",'account/chceckups_cost/'+(ui.item.id)+'/1');
				$("#searched_patient").show('slow');
			}
		});
	});

	</script>
	<input type="hidden" value="" id="searched_id" name="searched_id"/>
	<br>
	<label> Fast Search </label> <input id='patient_id2' type='text'>
	<br>
	<div id="searched_patient" style="display:none">
		<table  id='myTable' name='myTable' class='tablesorter' border='0' cellspacing='1' cellpadding='0'>
		<thead><tr>
			<th> <?php echo lang('general_code')?> </th>
			<th> <?php echo lang('form_label_name')?> </th>
			
			<th> <?php echo lang('form_label_history')?> </th>
                        <!-- <th> <?php echo lang('form_label_payment')?> </th> -->
			<th> <?php echo lang('form_label_details')?> </th>
		</tr>
		</thead>
		<tbody>
			<tr><?php
			echo "<td> <span id='code'></span> </td>";
			echo "<td> <span id='paname'></span> </td>";
			
			echo "<td>". anchor("patient/patient_history/" , lang('form_label_history'), "id=history_link")."</td>";
                        echo "<!-- <td>". anchor("account/chceckups_cost/" , lang('form_label_payment'), "id=payment_link")."</td> -->";
			echo "<td>". anchor("patient/patient_details/" , lang('form_label_details'), "id=details_link")."</td>";
			?></tr>
		</tbody>
		</table>
		
	</div>
	<br>
	<table  id='myTable' name='myTable' class='tablesorter' border='0' cellspacing='1' cellpadding='0'>
		<thead><tr>
			<th> # </th>
			<th> <?php echo lang('general_code')?> </th>
			<th> <?php echo lang('form_label_name')?> </th>
			<th> <?php echo lang('general_lastname')?> </th>
			<th> <?php echo lang('form_label_history')?> </th>
			<th> <?php echo lang('form_label_details')?> </th>
			<th> <?php echo lang('menuitem_edit')?> </th>
			<!-- <th> <?php echo lang('menuitem_delete')?> </th> -->
		</tr>
		</thead>
		<tbody>
	<?php 
		$i = 0;
		foreach($result as $row){
			echo "<tr>";
			echo "<td>". ++$i ."</td>";
			echo "<td>".$row['code']."</td>";
			echo "<td>".$row['first_name']."</td>";
			echo "<td>".$row['last_name']."</td>";
			echo "<td>". anchor("patient/patient_history/".$row['id'] , lang('form_label_history'))."</td>";
			echo "<td>". anchor("patient/patient_details/".$row['id'] , lang('form_label_details'))."</td>";
			echo "<td>". anchor("patient/new_patient/".$row['id'] , lang('menuitem_edit'))."</td>";
			echo "<!-- <td>". anchor("patient/delete_patient/".$row['id'] , lang('menuitem_delete'))."</td> -->";
			echo "</tr>";
		}
	echo "</table>";
	} //end if?>
